package at.jaki.ubb.crawling.appThreads;

import java.util.concurrent.Callable;

/**
 * data finders and data transformers created by the user, are wraped by a
 * Calleble class, that implements the functionalities require by the Crawling
 * engine. The abstract wrapper implements the common methods of these wrappers.
 * 
 * @author Attila Jakabfi
 * 
 */
public abstract class AbstractManagerWrapperThread<E> implements Callable<E>{
	
	private boolean busy;
	private String name;
	
	public void setName(String logName) {
		name = logName;
	}

	public String getName() {
		return name;
	}
	
	public final boolean isBusy() {
		return busy;
	}

	@Override
	public final E call() throws Exception {
		busy = true;
		try {
			return doWork();
		} finally {
			// even in case of exception clear the busy flag.
			busy = false;
		}
	}

	public abstract E doWork() throws Exception;

}
